<?php
include_once 'paomeBase.class.php';

/**
 * 分享授权
 */
class shareModel extends paomeBaseModel
{
    private $_appId = 'wx6e9f935be224ef2e';
    private $_appSecret = 'fda90d889cf846234720ee5d414a336c';
    private $_uri = 'https://open.weixin.qq.com/connect/oauth2/';
    private $_redirectUrl = "http://irun.hupu.com/paome_share/wxcallback";

    public function __construct(& $base)
    {
        parent::__construct($base);

        $this->table = 'r_pm_supporters';
    }

    /**
    * 微信授权
    */
    public function pubOpenIdUrl($uid = null)
    {
        $state = md5($this->_appId . $this->_appSecret . time());
        $param = array(
            'appid' => $this->_appId,
            'redirect_uri' => $this->_redirectUrl . '?target_uid='.$uid,
            'response_type' => 'code',
            'scope' => 'snsapi_base',
            'state' => $state
        );
        $param = http_build_query($param);
        return $this->_uri ."authorize?" . $param . "#wechat_redirect";
    }
}